package com.guli.vodtest;

import com.aliyuncs.DefaultAcsClient;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.vod.model.v20170321.GetPlayInfoRequest;
import com.aliyuncs.vod.model.v20170321.GetPlayInfoResponse;

import java.util.List;

/**
 * @author zxc
 * @date 2023/04/08 15:12
 **/
// 根据音视频id，来获取播放音视频地址;
public class VodDemo1 {
    public static void main(String[] args) throws ClientException {
        // 根据视频id，来获取播放音视频地址
        // 1.创建初始化HttpClient对象
        DefaultAcsClient client = VodInit.initVodClient("LTAI5tGoduzd9bgBczsfeL6K", "Bggqknbss9p7o5lUE6sEvVZc3ZuwoL");

        // 2.创建获取音视频地址的request && response;
        GetPlayInfoRequest request = new GetPlayInfoRequest();
        GetPlayInfoResponse response = new GetPlayInfoResponse();

        // 3.向request对象中，传入所要获取的视频id;
        request.setVideoId("a5339850d5f171ed80340764b3ec0102");

        // 4.调用client对象中所封装的方法，以request作为参数进行传递，使用response来接收所产生结果;
        response = client.getAcsResponse(request);

        // 获取response中所存储的数据
        List<GetPlayInfoResponse.PlayInfo> playInfoList = response.getPlayInfoList();
        for (GetPlayInfoResponse.PlayInfo playInfo : playInfoList) {
            System.out.println("PlayURL : " + playInfo.getPlayURL());
        }
        System.out.println("VideoId = " + response.getVideoBase().getVideoId());
        System.out.println("Title = " + response.getVideoBase().getTitle());
        System.out.println("RequestId = " + response.getRequestId());
    }
}
